-
-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add check for fileName in eraseBookFilesFromComputer #816
Conversation
Without this check, the function will delete all files in the directory if fileName is "*" This commit also adds camelCase in some places
This change adds the check which should fix the problem reported but I don't understand why is there a need to add |
@juuz0 Thank you for the super quick patch. I suspect this is needed to delete all files in case of a splitted ZIM file. |
@juuz0 The bug to me is more that under certain circunstances |
Not a clear idea but as you mentioned probably because the download has failed and this book is not added in library then?
I considered this but
|
We can leave it like it is then, if this seems legit to call
There is quite a few things to say here IMO:
Actually quite a few things are NOK to me. If all my remarks bother you ;) then just leave it, will try to propose an other PR later this week. |
I think doing file deletions with * is a bad thing. |
The path of the book is set once the download is finished (https://github.com/kiwix/kiwix-desktop/blob/master/src/contentmanager.cpp#L165). Before that, the book is a copy of what is the remote library and, obviously, it hasn't a (local) path. We probably have to:
|
QString dirPath = QString::fromStdString(kiwix::removeLastPathElement(book.getPath())); | ||
QString filename = QString::fromStdString(kiwix::getLastPathElement(book.getPath())) + "*"; | ||
eraseBookFilesFromComputer(dirPath, filename); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is probably to eraseBookFilesFromComputer
to split the bookPath and erase book properly.
The signature of the method should probably be:
bool eraseBookFilesFromComputer(const Book& book)
This fixed issue is really important. |
👍 I will follow all inputs above |
Fix #809